import React from 'react';

interface Props { text: string; language?: string; }

const CodeBlock: React.FC<Props> = ({ text }) => {
  const handleCopy = async () => {
    try { await navigator.clipboard.writeText(text); } catch {}
  };
  return (
    <div>
      <pre className="code"><code>{text}</code></pre>
      <div style={{ textAlign: 'right' }}>
        <a onClick={handleCopy}>复制</a>
      </div>
    </div>
  );
};

export default CodeBlock;

